package acm.同步赛4;

import java.util.Arrays;
import java.util.Scanner;

public class E {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] pass=new int[sc.nextInt()];
        int[] grades=new int[sc.nextInt()];
        for (int i = 0; i < pass.length; i++) {
            pass[i]=sc.nextInt();
        }
        Arrays.sort(pass);
        int res=0;
        for (int i = 0; i < grades.length; i++) {
            grades[i]= sc.nextInt();
            res+=search(pass,grades[i]);
        }
        System.out.println(res);
    }
    public static int search(int[] pass,int grade){
        int L=0,R=pass.length-1;
        //找到第一个比自己小的位置，和第一个比自己大的
        while(L<=R){
            int mid=(L+R)>>1;
            if (pass[mid]==grade){
                return 0;
            }
            if (grade<pass[mid]){
                R=mid-1;
            }else {
                L=mid+1;
            }
        }
        int more=Integer.MAX_VALUE;
        int small=Integer.MAX_VALUE;
        //1   3  5   9  //当L>R && L<length时，R是第一个比grade小的，L是第一个比grade大的
        if (L<pass.length){
            more=pass[L]-grade;
        }
        if (R>=0){
            small=grade-pass[R];
        }
        return Math.min(small,more);
    }
}
